package me.heizi.springboot.students.controllers.exceptions

import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestControllerAdvice
import kotlin.Exception


@RestControllerAdvice
class Handler {
    @ExceptionHandler(NullPointerException::class)
    fun `404`()= ResponseEntity<Nothing>(HttpStatus.NOT_FOUND)

    @ExceptionHandler(IllegalArgumentException::class)
    fun `400`() = ResponseEntity<Nothing>(HttpStatus.BAD_REQUEST)

    @ExceptionHandler(Exception::class)
    fun `500`(exception: Exception) = ResponseEntity<String>(exception.message,HttpStatus.INTERNAL_SERVER_ERROR)

}